home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvmtest / test_util.c < prev    next >
C/C++ Source or Header  |  1997-08-06  |  41KB  |  1,207 lines

  1. /****************************************/
  2. /*    test_util.c            */
  3. /*    miscelleanous functions        */
  4. /****************************************/
  5.  
  6. #include "pvm_test.h"
  7. #include "test_list.h"
  8.  
  9. /****************************************/
  10. /*        Terminate        */
  11. /****************************************/
  12.  
  13. void term(code)
  14. int    code;
  15. {
  16. if (code == HIGH_LEVEL)
  17.     fprintf(outfile,"\n\n********************\n* PVM_tester exits *\n********************\n\n");
  18. if (code == OK_LEVEL)
  19.     fprintf(outfile,"\n\n--------------------\n|  PVM tester End  |\n--------------------\n\n");
  20.     if(out45)fclose(out45);
  21.     if(out46)fclose(out46);
  22.     fclose(stderr);
  23.     if (stdout != stderr)
  24.         fclose(stdout);
  25.     if (outfile != stdout)
  26.         fclose(outfile);
  27. fprintf(stderr,"PVM still running\n");
  28. /*
  29.     if (pvm_halt()<0)
  30.         fprintf(outfile,"pvm_halt() : Unable to stop pvmd !!!\n");
  31. */
  32. exit(1);
  33. }
  34.  
  35.  
  36. /****************************************/
  37. /*    Input file Parsing        */
  38. /****************************************/
  39.  
  40. int input_parse(infile,name,number_of_hosts,myhostname,out)
  41. FILE     *infile;
  42. char     *name;
  43. int      *number_of_hosts;
  44. char    *myhostname;
  45. char    out[OUTFILE_MAX_LENGTH];
  46. {
  47. int      i,value,flag,test_number,linecount=0;
  48. char     line[MAX_LINE_LENGTH];            /* Current line proc*/
  49. char    temp_buf[32];
  50. int    myhost_already_seen=0;
  51.  
  52. /*    File Open        */
  53. if((infile = fopen(name,"r")) == NULL)
  54.     {
  55.     fprintf(stderr, "fopen() : Unable to open %s for input: ",name);
  56.     exit(1);
  57.     }
  58.  
  59. /*    File parse        */
  60. while(fgets(line,MAX_LINE_LENGTH,infile) != NULL)
  61.     {
  62.     linecount++;
  63.     if(line[0] != '#')     /* We ignore the comments */
  64.         {
  65.         if(strncmp(line,HOST_PREFIX,strlen(HOST_PREFIX)) == 0)
  66.             /***** Add an host to hostpool *****/
  67.             {
  68.             if ((strlen(line)-strlen(HOST_PREFIX))> MAX_HOST_NAME_LENGTH)
  69.                 {
  70.                 fprintf(stderr,"Host name too long on line %d\n",
  71.                         linecount);
  72.                 exit(1);
  73.                 }
  74.             if ((strncmp(myhostname,(line+strlen(HOST_PREFIX)),
  75.                 strlen(line)-strlen(HOST_PREFIX)-1)!=0)||(myhost_already_seen == 1))
  76.                 {
  77.             hostpool[*number_of_hosts] = (char *)malloc(strlen(line)-strlen(HOST_PREFIX)+1);
  78.             strncpy(hostpool[*number_of_hosts],(line+strlen(HOST_PREFIX)),
  79.                         strlen(line)-strlen(HOST_PREFIX)-1);    
  80.             hostpool[*number_of_hosts][strlen(line)-strlen(HOST_PREFIX)-1]='\0';
  81.             (*number_of_hosts)++;
  82.                 }
  83.             else    /* It is myhost */
  84.                 myhost_already_seen = 1;
  85.             }
  86.         else if(strncmp(line,"[",1) == 0)
  87.             /***** Do we execute this test *****/
  88.             {
  89.             if((flag = parse_flag(line)) == -1)
  90.                 {
  91.                 fprintf(stderr,"Error in input file at line %d\n", 
  92.                         linecount);
  93.                 fclose(infile);
  94.                 exit(1);
  95.                 }
  96.             if((test_number = parse_test_number(line,flag)) == -1)
  97.                 {
  98.                 fprintf(stderr,"Error in input file at line %d\n",
  99.                         linecount);
  100.                 fclose(infile);
  101.                 exit(1);
  102.                            }
  103.             if(test_number > NUMBER_OF_TESTS)
  104.                 {
  105.                 fprintf(stderr,"No such test at line %d\n",linecount);
  106.                 exit(1);
  107.                 }
  108.             (*masters)[(test_number-1)].flag.perform=flag;
  109.             }
  110.         else if(strncmp(line,OUTFILE_PREFIX,strlen(OUTFILE_PREFIX)) == 0)
  111.             /***** Set outfile *****/
  112.             {
  113.             if ((strlen(line)-strlen(OUTFILE_PREFIX)) > OUTFILE_MAX_LENGTH)
  114.                 {
  115.                 fprintf(stderr,"Outfile too long on line %d\n",
  116.                         linecount);
  117.                 exit(1);
  118.                 }
  119.             strncpy(out,line+strlen(OUTFILE_PREFIX),
  120.                 strlen(line)-strlen(OUTFILE_PREFIX)-1);
  121.             out[strlen(line)-strlen(OUTFILE_PREFIX)-1] = '\0';
  122.             if (strcmp(out,"stdout") == 0)
  123.                 outfile = stdout;
  124.             else
  125.                 if ((outfile = fopen(out,"w")) == NULL)
  126.                     {
  127.                     fprintf(stderr,"fopen() : Unable to open %s\n",out);
  128.                     exit(1);
  129.                     }
  130.             }
  131.         else if(strncmp(line,MAX_LENGTH_PREFIX,strlen(MAX_LENGTH_PREFIX)) == 0)
  132.             /***** Set max_size *****/
  133.             {
  134.             if ((strlen(line)-strlen(MAX_LENGTH_PREFIX))>9)
  135.                 {
  136.                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  137.                 exit(1);
  138.                 }
  139.             for (i=strlen(MAX_LENGTH_PREFIX);i<strlen(line)-1;i++)
  140.                 {
  141.                 if ((line[i]<'0')||(line[i]>'9'))
  142.                     {
  143.                     fprintf(stderr,"Error in input file at line %d\n",linecount);
  144.                     exit(1);
  145.                     }
  146.                 temp_buf[i-strlen(MAX_LENGTH_PREFIX)]=line[i];
  147.                 }
  148.             max_size = atoi(temp_buf);
  149.             if (max_size>MAX_MESSAGE_LENGTH)
  150.                 {
  151.                 max_size = MAX_MESSAGE_LENGTH;
  152.                 fprintf(stderr,"\tMax Size of message too long, using %d by default\n",MAX_MESSAGE_LENGTH);
  153.                 }
  154.             for (i=0;i<10;i++) temp_buf[i]=' ';
  155.             }
  156.         else if(strncmp(line,START_LENGTH_PREFIX,strlen(START_LENGTH_PREFIX)) == 0)
  157.                         /***** Set start_size *****/
  158.                         {
  159.                         if ((strlen(line)-strlen(START_LENGTH_PREFIX))>9)
  160.                                 {
  161.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  162.                                 exit(1);
  163.                                 }
  164.                         for (i=strlen(START_LENGTH_PREFIX);i<strlen(line)-1;i++)
  165.                                 {
  166.                                 if ((line[i]<'0')||(line[i]>'9'))
  167.                                         {
  168.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  169.                                         exit(1);
  170.                                         }
  171.                                 temp_buf[i-strlen(START_LENGTH_PREFIX)]=line[i];
  172.                                 }
  173.                         start_size = atoi(temp_buf);
  174.             if (start_size >MAX_MESSAGE_LENGTH)
  175.                 {
  176.                 start_size = MAX_MESSAGE_LENGTH;
  177.                 fprintf(stderr,"\tStart size of message too long, using %d by default\n",MAX_MESSAGE_LENGTH);
  178.                 }
  179.             for (i=0;i<10;i++) temp_buf[i]=' ';
  180.                         }
  181.         else if(strncmp(line,INCR_PREFIX,strlen(INCR_PREFIX)) == 0)
  182.                         /***** Set incr *****/
  183.                         {
  184.                         if ((strlen(line)-strlen(INCR_PREFIX))>9)
  185.                                 {
  186.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  187.                                 exit(1);
  188.                                 }
  189.                         for (i=strlen(INCR_PREFIX);i<strlen(line)-1;i++)
  190.                                 {
  191.                                 if ((line[i]<'0')||(line[i]>'9'))
  192.                                         {
  193.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  194.                                         exit(1);
  195.                                         }
  196.                                 temp_buf[i-strlen(INCR_PREFIX)]=line[i];
  197.                                 }
  198.                         incr = atoi(temp_buf);
  199.             for (i=0;i<10;i++) temp_buf[i]=' ';
  200.                         }
  201.         else if(strncmp(line,NUM_PREFIX,strlen(NUM_PREFIX)) == 0)
  202.                         /***** Set num_message *****/
  203.                         {
  204.                         if ((strlen(line)-strlen(NUM_PREFIX))>9)
  205.                                 {
  206.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  207.                                 exit(1);
  208.                                 }
  209.                         for (i=strlen(NUM_PREFIX);i<strlen(line)-1;i++)
  210.                                 {
  211.                                 if ((line[i]<'0')||(line[i]>'9'))
  212.                                         {
  213.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  214.                                         exit(1);
  215.                                         }
  216.                                 temp_buf[i-strlen(NUM_PREFIX)]=line[i];
  217.                                 }
  218.                         num_messages = atoi(temp_buf);
  219.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  220.                         }
  221.         else if(strncmp(line,LENGTH_PREFIX,strlen(LENGTH_PREFIX)) == 0)
  222.                         /***** Set message_length *****/
  223.                         {
  224.                         if ((strlen(line)-strlen(LENGTH_PREFIX))>9)
  225.                                 {
  226.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  227.                                 exit(1);
  228.                                 }
  229.                         for (i=strlen(LENGTH_PREFIX);i<strlen(line)-1;i++)
  230.                                 {
  231.                                 if ((line[i]<'0')||(line[i]>'9'))
  232.                                         {
  233.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  234.                                         exit(1);
  235.                                         }
  236.                                 temp_buf[i-strlen(LENGTH_PREFIX)]=line[i];
  237.                                 }
  238.                         messages_length = atoi(temp_buf);
  239.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  240.                         }
  241.          else if(strncmp(line,FUNNELING_PREFIX,strlen(FUNNELING_PREFIX)) == 0)
  242.                         /***** set funneling  *****/
  243.                         {
  244.                         if ((strlen(line)-strlen(FUNNELING_PREFIX))>9)
  245.                                 {
  246.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  247.                                 exit(1);
  248.                                 }
  249.                         for (i=strlen(FUNNELING_PREFIX);i<strlen(line)-1;i++)
  250.                                 {
  251.                                 if ((line[i]<'0')||(line[i]>'9'))
  252.                                         {
  253.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  254.                                         exit(1);
  255.                                         }
  256.                                 temp_buf[i-strlen(FUNNELING_PREFIX)]=line[i];
  257.                                 }
  258.             value = atoi(temp_buf);
  259.             for (i=79;i<107;i++)
  260.                 {
  261.                 (*masters)[i].num_req_hosts=value;
  262.                 (*masters)[i].flag.after_hosts=value;
  263.                 }
  264.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  265.             }
  266.         else if(strncmp(line,COMBOS_PREFIX,strlen(COMBOS_PREFIX)) == 0)
  267.                         /***** set all_combos  *****/
  268.                         {
  269.                         if ((strlen(line)-strlen(COMBOS_PREFIX))>9)
  270.                                 {
  271.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  272.                                 exit(1);
  273.                                 }
  274.                         for (i=strlen(COMBOS_PREFIX);i<strlen(line)-1;i++)
  275.                                 {
  276.                                 if ((line[i]<'0')||(line[i]>'1'))
  277.                                         {
  278.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  279.                                         exit(1);
  280.                                         }
  281.                                 temp_buf[i-strlen(COMBOS_PREFIX)]=line[i];
  282.                                 }
  283.                         value = atoi(temp_buf);
  284.             if ((value != 0)&&(value !=1))
  285.                 {
  286.                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  287.                 exit(1);
  288.                 }
  289.             all_combos = value;    
  290.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  291.                         }
  292.                 else if(strncmp(line,ALL_TESTS_PREFIX,strlen(ALL_TESTS_PREFIX)) == 0)
  293.                         /***** set all_tests  *****/
  294.                         {
  295.                         if ((strlen(line)-strlen(ALL_TESTS_PREFIX))>9)
  296.                                 {
  297.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  298.                                 exit(1);
  299.                                 }
  300.                         for (i=strlen(ALL_TESTS_PREFIX);i<strlen(line)-1;i++)
  301.                                 {
  302.                                 if ((line[i]<'0')||(line[i]>'9'))
  303.                                         {
  304.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  305.                                         exit(1);
  306.                                         }
  307.                                 temp_buf[i-strlen(ALL_TESTS_PREFIX)]=line[i];
  308.                                 }
  309.                         value = atoi(temp_buf);
  310.                         if ((value != 0)&&(value !=1))
  311.                                 {
  312.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  313.                                 exit(1);
  314.                                 }
  315.             all_tests = value;
  316.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  317.                         }
  318.  
  319.                 else if(strncmp(line,ALL_MESSAGING_PREFIX,strlen(ALL_MESSAGING_PREFIX)) == 0)
  320.                         /***** set all_messaging  *****/
  321.                         {
  322.                         if ((strlen(line)-strlen(ALL_MESSAGING_PREFIX))>9)
  323.                                 {
  324.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  325.                                 exit(1);
  326.                                 }
  327.                         for (i=strlen(ALL_MESSAGING_PREFIX);i<strlen(line)-1;i++)
  328.                                 {
  329.                                 if ((line[i]<'0')||(line[i]>'9'))
  330.                                         {
  331.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  332.                                         exit(1);
  333.                                         }
  334.                                 temp_buf[i-strlen(ALL_MESSAGING_PREFIX)]=line[i];
  335.                                 }
  336.                         value = atoi(temp_buf);
  337.                         if ((value != 0)&&(value !=1))
  338.                                 {
  339.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  340.                                 exit(1);
  341.                                 }
  342.                         all_messaging = value;
  343.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  344.                         }
  345.  
  346.                 else if(strncmp(line,ALL_ROUTINE_PREFIX,strlen(ALL_ROUTINE_PREFIX)) == 0)
  347.                         /***** set all_routine  *****/
  348.                         {
  349.                         if ((strlen(line)-strlen(ALL_ROUTINE_PREFIX))>9)
  350.                                 {
  351.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  352.                                 exit(1);
  353.                                 }
  354.                         for (i=strlen(ALL_ROUTINE_PREFIX);i<strlen(line)-1;i++)
  355.                                 {
  356.                                 if ((line[i]<'0')||(line[i]>'9'))
  357.                                         {
  358.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  359.                                         exit(1);
  360.                                         }
  361.                                 temp_buf[i-strlen(ALL_ROUTINE_PREFIX)]=line[i];
  362.                                 }
  363.                         value = atoi(temp_buf);
  364.                         if ((value != 0)&&(value !=1))
  365.                                 {
  366.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  367.                                 exit(1);
  368.                                 }
  369.                         all_routine = value;
  370.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  371.                         }
  372.  
  373.                 else if(strncmp(line,ALL_FUNNEL_NODATA_PREFIX,strlen(ALL_FUNNEL_NODATA_PREFIX)) == 0)
  374.                         /***** set all_funnel_nodata  *****/
  375.                         {
  376.                         if ((strlen(line)-strlen(ALL_FUNNEL_NODATA_PREFIX))>9)
  377.                                 {
  378.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  379.                                 exit(1);
  380.                                 }
  381.                         for (i=strlen(ALL_FUNNEL_NODATA_PREFIX);i<strlen(line)-1;i++)
  382.                                 {
  383.                                 if ((line[i]<'0')||(line[i]>'9'))
  384.                                         {
  385.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  386.                                         exit(1);
  387.                                         }
  388.                                 temp_buf[i-strlen(ALL_FUNNEL_NODATA_PREFIX)]=line[i];
  389.                                 }
  390.                         value = atoi(temp_buf);
  391.                         if ((value != 0)&&(value !=1))
  392.                                 {
  393.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  394.                                 exit(1);
  395.                                 }
  396.                         all_funnel_nodata = value;
  397.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  398.                         }
  399.  
  400.                 else if(strncmp(line,ALL_FUNNEL_DATA_PREFIX,strlen(ALL_FUNNEL_DATA_PREFIX)) == 0)
  401.                         /***** set all_funnel_data  *****/
  402.                         {
  403.                         if ((strlen(line)-strlen(ALL_FUNNEL_DATA_PREFIX))>9)
  404.                                 {
  405.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  406.                                 exit(1);
  407.                                 }
  408.                         for (i=strlen(ALL_FUNNEL_DATA_PREFIX);i<strlen(line)-1;i++)
  409.                                 {
  410.                                 if ((line[i]<'0')||(line[i]>'9'))
  411.                                         {
  412.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  413.                                         exit(1);
  414.                                         }
  415.                                 temp_buf[i-strlen(ALL_FUNNEL_DATA_PREFIX)]=line[i];
  416.                                 }
  417.                         value = atoi(temp_buf);
  418.                         if ((value != 0)&&(value !=1))
  419.                                 {
  420.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  421.                                 exit(1);
  422.                                 }
  423.                         all_funnel_data = value;
  424.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  425.                         }
  426.                 else if(strncmp(line,ALL_HEAD_NODATA_PREFIX,strlen(ALL_HEAD_NODATA_PREFIX)) == 0)
  427.                         /***** set all_head_nodata  *****/
  428.                         {
  429.                         if ((strlen(line)-strlen(ALL_HEAD_NODATA_PREFIX))>9)
  430.                                 {
  431.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  432.                                 exit(1);
  433.                                 }
  434.                         for (i=strlen(ALL_HEAD_NODATA_PREFIX);i<strlen(line)-1;i++)
  435.                                 {
  436.                                 if ((line[i]<'0')||(line[i]>'9'))
  437.                                         {
  438.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  439.                                         exit(1);
  440.                                         }
  441.                                 temp_buf[i-strlen(ALL_HEAD_NODATA_PREFIX)]=line[i];
  442.                                 }
  443.                         value = atoi(temp_buf);
  444.                         if ((value != 0)&&(value !=1))
  445.                                 {
  446.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  447.                                 exit(1);
  448.                                 }
  449.                         all_head_nodata = value;
  450.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  451.                         }
  452.  
  453.                 else if(strncmp(line,ALL_HEAD_DATA_PREFIX,strlen(ALL_HEAD_DATA_PREFIX)) == 0)
  454.                         /***** set all_head_data  *****/
  455.                         {
  456.                         if ((strlen(line)-strlen(ALL_HEAD_DATA_PREFIX))>9)
  457.                                 {
  458.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  459.                                 exit(1);
  460.                                 }
  461.                         for (i=strlen(ALL_HEAD_DATA_PREFIX);i<strlen(line)-1;i++)
  462.                                 {
  463.                                 if ((line[i]<'0')||(line[i]>'9'))
  464.                                         {
  465.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  466.                                         exit(1);
  467.                                         }
  468.                                 temp_buf[i-strlen(ALL_HEAD_DATA_PREFIX)]=line[i];
  469.                                 }
  470.                         value = atoi(temp_buf);
  471.                         if ((value != 0)&&(value !=1))
  472.                                 {
  473.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  474.                                 exit(1);
  475.                                 }
  476.                         all_head_data = value;
  477.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  478.                         }
  479.                 else if(strncmp(line,ALL_TRIANGLE_NODATA_PREFIX,strlen(ALL_TRIANGLE_NODATA_PREFIX)) == 0)
  480.                         /***** set all_triangle_nodata  *****/
  481.                         {
  482.                         if ((strlen(line)-strlen(ALL_TRIANGLE_NODATA_PREFIX))>9)
  483.                                 {
  484.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  485.                                 exit(1);
  486.                                 }
  487.                         for (i=strlen(ALL_TRIANGLE_NODATA_PREFIX);i<strlen(line)-1;i++)
  488.                                 {
  489.                                 if ((line[i]<'0')||(line[i]>'9'))
  490.                                         {
  491.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  492.                                         exit(1);
  493.                                         }
  494.                                 temp_buf[i-strlen(ALL_TRIANGLE_NODATA_PREFIX)]=line[i];
  495.                                 }
  496.                         value = atoi(temp_buf);
  497.                         if ((value != 0)&&(value !=1))
  498.                                 {
  499.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  500.                                 exit(1);
  501.                                 }
  502.                         all_triangle_nodata = value;
  503.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  504.                         }
  505.  
  506.                 else if(strncmp(line,ALL_TRIANGLE_DATA_PREFIX,strlen(ALL_TRIANGLE_DATA_PREFIX)) == 0)
  507.                         /***** set all_triangle_data  *****/
  508.                         {
  509.                         if ((strlen(line)-strlen(ALL_TRIANGLE_DATA_PREFIX))>9)
  510.                                 {
  511.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  512.                                 exit(1);
  513.                                 }
  514.                         for (i=strlen(ALL_TRIANGLE_DATA_PREFIX);i<strlen(line)-1;i++)
  515.                                 {
  516.                                 if ((line[i]<'0')||(line[i]>'9'))
  517.                                         {
  518.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  519.                                         exit(1);
  520.                                         }
  521.                                 temp_buf[i-strlen(ALL_TRIANGLE_DATA_PREFIX)]=line[i];
  522.                                 }
  523.                         value = atoi(temp_buf);
  524.                         if ((value != 0)&&(value !=1))
  525.                                 {
  526.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  527.                                 exit(1);
  528.                                 }
  529.                         all_triangle_data = value;
  530.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  531.                         }
  532.  
  533.                 else if(strncmp(line,ALL_PERF_PREFIX,strlen(ALL_PERF_PREFIX)) == 0)
  534.                         /***** set all_perf  *****/
  535.                         {
  536.                         if ((strlen(line)-strlen(ALL_PERF_PREFIX))>9)
  537.                                 {
  538.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  539.                                 exit(1);
  540.                                 }
  541.                         for (i=strlen(ALL_PERF_PREFIX);i<strlen(line)-1;i++)
  542.                                 {
  543.                                 if ((line[i]<'0')||(line[i]>'9'))
  544.                                         {
  545.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  546.                                         exit(1);
  547.                                         }
  548.                                 temp_buf[i-strlen(ALL_PERF_PREFIX)]=line[i];
  549.                                 }
  550.                         value = atoi(temp_buf);
  551.                         if ((value != 0)&&(value !=1))
  552.                                 {
  553.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  554.                                 exit(1);
  555.                                 }
  556.                         all_perf = value;
  557.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  558.                         }
  559.  
  560.         else if(strncmp(line,TIMING_TOTAL_PREFIX,strlen(TIMING_TOTAL_PREFIX)) == 0)
  561.                         /***** set timing_total  *****/
  562.                         {
  563.                         if ((strlen(line)-strlen(TIMING_TOTAL_PREFIX))>9)
  564.                                 {
  565.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  566.                                 exit(1);
  567.                                 }
  568.                         for (i=strlen(TIMING_TOTAL_PREFIX);i<strlen(line)-1;i++)
  569.                                 {
  570.                                 if ((line[i]<'0')||(line[i]>'9'))
  571.                                         {
  572.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  573.                                         exit(1);
  574.                                         }
  575.                                 temp_buf[i-strlen(TIMING_TOTAL_PREFIX)]=line[i];
  576.                                 }
  577.                         value = atoi(temp_buf);
  578.                         if ((value != 0)&&(value !=1))
  579.                                 {
  580.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  581.                                 exit(1);
  582.                                 }
  583.                         timing_total = value;
  584.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  585.                         }
  586.         else if(strncmp(line,TIMING_AVERAGE_PREFIX,strlen(TIMING_AVERAGE_PREFIX)) == 0)
  587.                         /***** set timing_AVERAGE  *****/
  588.                         {
  589.                         if ((strlen(line)-strlen(TIMING_AVERAGE_PREFIX))>9)
  590.                                 {
  591.                                 fprintf(stderr,"Number to long in input file at line %d\n",linecount);
  592.                                 exit(1);
  593.                                 }
  594.                         for (i=strlen(TIMING_AVERAGE_PREFIX);i<strlen(line)-1;i++)
  595.                                 {
  596.                                 if ((line[i]<'0')||(line[i]>'9'))
  597.                                         {
  598.                                         fprintf(stderr,"Error in input file at line %d\n",linecount);
  599.                                         exit(1);
  600.                                         }
  601.                                 temp_buf[i-strlen(TIMING_AVERAGE_PREFIX)]=line[i];
  602.                                 }
  603.                         value = atoi(temp_buf);
  604.                         if ((value != 0)&&(value !=1))
  605.                                 {
  606.                                 fprintf(stderr,"Should be a 0 or a 1 at line %d\n",linecount);
  607.                                 exit(1);
  608.                                 }
  609.                         timing_average = value;
  610.                         for (i=0;i<10;i++) temp_buf[i]=' ';
  611.                         }
  612.  
  613.  
  614.  
  615.  
  616.                     
  617.         else
  618.             /***** Error *****/
  619.             {
  620.             fprintf(stderr,"Error in input file at line %d\n",
  621.                        linecount);
  622.             fclose(infile);
  623.             exit(1);
  624.             }
  625.  
  626.         }
  627.     }
  628. if (outfile == NULL)
  629.     outfile = stdout;
  630. if (fclose(infile) == -1)
  631.     {
  632.     fprintf(stderr,"fclose() : Unable to close the input file \n");
  633.     exit(1);
  634.     }
  635. }
  636.  
  637. /****************************************/
  638. /*      Group Server init        */
  639. /****************************************/
  640.  
  641. int start_group_server()
  642. {
  643. int    info;
  644. /* Start pvm group server */
  645. fprintf(stderr,"Starting pvm group server.....\n");
  646. if ((info = pvm_joingroup("Group_init")) != 0)
  647.     {
  648.     fprintf(stderr,
  649.         "pvm_joingroup() : Failed with error %d. Impossible to start group server\n",info);
  650.     return -1;
  651.     }
  652. return 1;
  653. }
  654.  
  655.  
  656. /****************************************/
  657. /*      PVM     Check host list        */
  658. /****************************************/
  659.  
  660. int check_hosts(num_hosts)
  661. int     num_hosts;
  662. {
  663. int     info;
  664. int     *infos=(int *)malloc(sizeof(int)*num_hosts);
  665. int     i;
  666.  
  667. fprintf(stderr,"Building Virtual machine....\n");
  668. if (num_hosts == 1)
  669.     return 1;
  670. if((info = pvm_addhosts(hostpool+1,num_hosts-1,infos)) < 0)
  671.     {
  672.     fprintf(outfile,"\tpvm_addhosts() :Failed with error %d\n",info);
  673.     free(infos);
  674.     return -1;
  675.     }
  676. if (info <num_hosts-1 )
  677.     {
  678.     for (i=0;i<num_hosts-1;i++)
  679.             {
  680.             if (*(infos+i) < 0)
  681.             fprintf(outfile,"\tpvm_addhost() failed for host %s with error %d\n",
  682.                 hostpool[i+1],*(infos+i));
  683.             }
  684.     free(infos);
  685.     return -1;
  686.     }
  687. if (wait_number_hosts(num_hosts-1) <0 )
  688.     {
  689.     free(infos);
  690.     return -1;
  691.     }
  692. free(infos);
  693. return 1;
  694. }    /* At this point, all hosts are added */
  695.  
  696.  
  697.  
  698.     
  699. /****************************************/
  700. /*    Get arch for hostpool        */
  701. /****************************************/
  702.  
  703. int get_all_arch()     /* Remove all host but master pvmd's host */
  704. {
  705. struct pvmhostinfo     *hostp;
  706. int             nhost;
  707. int             info;
  708. int            narch;
  709. int             i;
  710.  
  711. fprintf(stderr,"Getting the ARCH ...\n");
  712. if ((info = pvm_config(&nhost,&narch,&hostp)) < 0)
  713.     {
  714. printf("B\n");
  715.     fprintf(outfile,"\tpvm_config() : Failed with error %d\n",info);
  716.     return -1;
  717.     }
  718. /* We start at 1 to avoid the master host     */
  719. for(i=1;i<nhost;i++)
  720.     {
  721.     if (strcmp(hostp[i].hi_name,hostpool[i]) != 0)
  722.         {
  723.         fprintf(outfile,"\tIncoherent response from pvm_config compared to previous responses \n");
  724.         return -1;
  725.         }
  726.     strcpy(hostarch[i]=(char *)malloc(strlen(hostp[i].hi_arch)+1),hostp[i].hi_arch);
  727.     }
  728. return 0;
  729. }
  730.  
  731. /****************************************/
  732. /*    Get number of diff arch        */
  733. /****************************************/
  734.  
  735. int get_num_diff_arch(num_hosts)
  736. int     num_hosts;
  737. {
  738. char    temp[MAX_HOST][25];
  739. int     result=0;
  740. int     trouve;
  741. int     i,j;
  742.  
  743. for (i=1;i<num_hosts;i++)
  744.     {
  745.     trouve = 0;
  746.     for (j=0;j<result;j++)
  747.         trouve = trouve || (strcmp(hostarch[i],temp[j]) == 0);
  748.     if (!trouve)
  749.         strcpy(temp[result++],hostarch[i]);
  750.     }
  751. for (i=0;i<result;i++)
  752.     strcpy(diff_arch[i]=(char *)malloc(strlen(temp[i])+1),temp[i]);
  753.  
  754. return result;
  755. }
  756.  
  757. /****************************************/
  758. /*      PVM Remove all hosts        */
  759. /****************************************/
  760.  
  761. int remove_all_hosts()    /* Remove all host but master pvmd's host */
  762. {
  763. struct pvmhostinfo     *hostp;
  764. char            **list_of_names;
  765. int             error_test = 0;
  766. int             nhost;
  767. int             info;
  768. int             infos;
  769. int            narch;
  770. int             i;
  771.  
  772. if ((info = pvm_config(&nhost,&narch,&hostp)) < 0)
  773.     {
  774.     fprintf(outfile,"\tpvm_config() : Failed with error %d\n",info);
  775.     return -1;
  776.     }
  777. /*printf("dans remove_all_host , je trouve %d hosts restant\n",nhost -1);*/
  778. list_of_names = (char **)malloc(nhost*sizeof(char *));
  779. for (i=1;i<nhost;i++)
  780.     strcpy(list_of_names[i]=(char *)malloc(strlen(hostp[i].hi_name)+1),hostp[i].hi_name);
  781.  
  782. for (i=1;i<nhost;i++)
  783.     {
  784. /*    putc ('.',stderr);*/
  785.     if ((info = pvm_delhosts(list_of_names+i,1,&infos)) < 1)
  786.         {
  787.         fprintf(outfile,"\tpvm_delhosts() : Failed with error %d on host %s\n",
  788.                     infos,list_of_names[i]);
  789.         error_test= -1;
  790.         }
  791.     if (info == 1)
  792.         {
  793.         info = wait_number_hosts(nhost-i-1);
  794.             if (info <0)
  795.                 error_test = -1;
  796.         }
  797.     }
  798. free(list_of_names);
  799. return error_test;
  800. }
  801.  
  802.  
  803. /****************************************/
  804. /*      Check version            */
  805. /****************************************/
  806.  
  807. int check_version(num_hosts,myversion)
  808. int     num_hosts;
  809. char    *myversion;
  810. {
  811. char    **version_table;
  812.  
  813. int     i,tid,bufid,info;
  814. int     error_test=0;
  815. char    **args=NULL;
  816.  
  817. version_table = (char **)malloc(num_hosts*sizeof(char *));
  818. for (i=1;i<num_hosts;i++)
  819.     version_table[i]=(char *)malloc(25*sizeof(char));
  820.  
  821. fprintf(stderr,"Checking the version...\n");
  822.  
  823. for (i=1; i<num_hosts;i++)
  824.     {               /* Spawn version_slave  */
  825.     if ((info = pvm_spawn(VERSION_SLAVE,args,PvmTaskHost,hostpool[i],1,&tid)) <0 )
  826.         {    
  827.         fprintf(outfile,"\tpvm_spawn() : Failed with error %d\n for host %s",info,hostpool[i]);
  828.         error_test = -1;
  829.         continue;
  830.         }
  831.     info = timeout_wait_message(-1,VERSION_TAG,i);
  832.     if (info < 0)
  833.         {
  834.         error_test = -1;
  835.         continue;
  836.         }
  837.     bufid = pvm_recv(-1,VERSION_TAG);
  838.     if (bufid <0)
  839.         {       
  840.         fprintf(outfile,"\tpvm_recv() : Failed with error %d\n",bufid);
  841.         error_test = -1;
  842.         continue;
  843.         }
  844.     info = pvm_upkstr(version_table[i]);
  845.     if (info <0)
  846.         {
  847.         fprintf(outfile,"\tpvm_upkstr() : Failed with error %d\n",info);
  848.         error_test = -1;
  849.         }
  850.     }
  851. if (error_test == -1)
  852.     return -1;
  853. /* Now the table is complete */
  854. for (i=1;i<num_hosts;i++)
  855.     {
  856.     if (strcmp(myversion,version_table[i]) != 0)
  857.         {
  858.         fprintf(outfile,"\tVersion Mismatch for host %s : version %s, master version :%s\n",
  859.             hostpool[i],version_table[i],myversion);
  860.         error_test = -1;
  861.         }
  862.     }
  863. free(version_table);
  864. return error_test;
  865. }
  866.  
  867. /****************************************/
  868. /*      Miscellenaous Printout        */
  869. /****************************************/
  870.  
  871. int print_out_misc(myversion,num_hosts,in,out)
  872. char    *myversion;
  873. int    num_hosts;
  874. char    *in;
  875. char    *out;
  876. {
  877. int     i;
  878.  
  879. fprintf(outfile,"PVM %s\n",myversion);
  880. fprintf(outfile,"------------------------------------\n");
  881.  
  882. fprintf(outfile,"host pool\n");
  883.  
  884. fprintf(outfile,"---------\n");
  885. fprintf(outfile,"(%s) \t%s \t<--- Master host\n",hostarch[0],hostpool[0]);
  886.  
  887. for (i=1;i<num_hosts;i++)
  888.     fprintf(outfile,"(%s) \t%s\n",hostarch[i],hostpool[i]);
  889. fprintf(outfile,"\ninput file\t\toutput file\n");
  890. fprintf(outfile,"----------\t\t-----------\n");
  891. fprintf(outfile,"%s\t\t\t%s\n",in,out);
  892. fprintf(outfile,"------------------------------------\n");
  893. if (outfile != stdout)
  894.     fprintf(stdout,"output file : %s\n",out);
  895.  
  896. }
  897.  
  898.  
  899. /****************************************/
  900. /*      Find Shuffle            */    
  901. /****************************************/
  902.  
  903. int find_shuffle(num_hosts,num_diff_arch,shuffle)
  904. int     num_hosts;
  905. int     num_diff_arch;
  906. int     shuffle[MAX_HOST];
  907. {
  908. int     i,k;
  909. int    info;
  910. int    num_computed=1;
  911. for (k=0;k<num_hosts;k++)
  912.     shuffle[k]=0;
  913. while(num_computed <num_hosts)
  914.     for (i=0;i<num_diff_arch;i++)
  915.         {
  916.         info = look_for_new_arch(num_hosts,i,shuffle,num_computed);
  917.         if (info >=0)
  918.             shuffle[num_computed++]=info;
  919.         }
  920. return 1;
  921. }
  922.  
  923. int    look_for_new_arch(num_hosts,arch,shuffle,num_computed)
  924. int    num_hosts;
  925. int    arch;
  926. int    shuffle[MAX_HOST];
  927. int    num_computed;
  928. {
  929. int    i,j;
  930. int test = 0;
  931.  
  932. for (i=1;i<num_hosts;i++)
  933.     {
  934.     test =0;
  935.     if (strcmp(hostarch[i],diff_arch[arch])==0)
  936.         {
  937.         for(j=1;j<num_computed;j++)
  938.             if (shuffle[j]==i)
  939.                 test = 1;
  940.         if (test == 0)
  941.             return i;
  942.         }
  943.     }
  944. return -1;
  945. }
  946.  
  947. /****************************************/
  948. /*      Allocate some hosts        */
  949. /****************************************/
  950.  
  951. int allocate(array,req,num_wanted)
  952. int    array[MAX_HOST];
  953. int    req;
  954. int    *num_wanted;
  955. {
  956. int     i,infos;
  957. int    error_test=0;
  958. int    count_zero=0;
  959.  
  960. for (i=0;i<req;i++)
  961.     {
  962.     if (array[i]==0)
  963.         {
  964.         count_zero++;
  965.         continue;
  966.         }
  967.     if (pvm_addhosts(&hostpool[array[i]],1,&infos) < 1)
  968.         {
  969.         fprintf(outfile,"\tpvm_addhosts() : Failed to add host %s with error = %d\n",
  970.             hostpool[array[i]],infos);
  971.         error_test = -1;
  972.         }
  973.     }
  974. if (error_test == -1)
  975.     return -1;
  976. *num_wanted = *num_wanted - count_zero+1;
  977. if (wait_number_hosts(req-count_zero) <0 )
  978.     return -1;
  979.  
  980. return error_test;
  981. }
  982.             
  983.  
  984. /****************************************/
  985. /*      Unexpected host killed        */
  986. /****************************************/
  987.  
  988. int unexpected_host_killed(num_wanted)
  989. int     num_wanted;
  990. {
  991. int    info;
  992. int    after;
  993. int    narch;
  994. struct    pvmhostinfo *hostp;
  995.  
  996. /*printf("J;entre dans unexpected host kill\n");*/
  997. /*
  998. for (i=0;i<num_hosts;i++)
  999.     {
  1000.     printf("host %s\n --> %d\n",hostpool[i],pvm_mstat(hostpool[i]));
  1001.     }
  1002. */
  1003. info = pvm_config(&after,&narch,&hostp);
  1004. if (info <0)
  1005.     {
  1006.     fprintf(outfile,"\tpvm_config() : Failed with error %d\n",info);
  1007.     return -2;
  1008.     }
  1009. after--;    /* We suppress the master */
  1010. if (after != num_wanted)
  1011.     {
  1012.     fprintf(outfile,"\t%d hosts expected, %d found\n",num_wanted,after);
  1013.     return -1;
  1014.     }
  1015. return 1;
  1016. }
  1017.  
  1018.  
  1019. /****************************************/
  1020. /*      Print test result        */
  1021. /****************************************/
  1022.  
  1023.  
  1024. void print_test_result(number)
  1025. int     number;
  1026. {
  1027. int     result = (*masters)[number].status;
  1028.  
  1029. if (result == 0)
  1030.     fprintf(outfile,"test#%d: NOT_YET_PROCESSED\n",number+1);
  1031. else if (result == 1)
  1032.     fprintf(outfile,"test#%d: PASSED\n",number+1);
  1033. else if (result == -1)
  1034.     fprintf(outfile,"test#%d: FAILED\n",number+1);
  1035. else if (result == -2)
  1036.     fprintf(outfile,"test#%d: NOT_COMPLETED\n",number+1);
  1037. else
  1038.     fprintf(outfile,"test#%d: UNDETERMINED  %d \n",number+1,result);
  1039.  
  1040. }
  1041.  
  1042. /****************************************/
  1043. /*      Wait for a number of hosts    */
  1044. /****************************************/
  1045.  
  1046. int wait_number_hosts(number)
  1047. int    number;
  1048. {
  1049. int count = 0;
  1050. int info;
  1051. int actual_num;
  1052. int    narch;
  1053. struct    pvmhostinfo *hostp;
  1054.  
  1055. /*printf("wait for number = %d\n",number);*/
  1056. info = pvm_config(&actual_num,&narch,&hostp);
  1057. if (info < 0)
  1058.               {
  1059.               fprintf(outfile,"\tpvm_config() : Failed with error %d\n",info);
  1060.               return -1;
  1061.         }
  1062. /*printf("actual count = %d\n",actual_num);*/
  1063. while((count <= TIMEOUT_ADD_DELETE)&&(actual_num != (number+1)))
  1064.         {
  1065. /*             putc ('.',stderr);*/
  1066.         if (info = pvm_config(&actual_num,&narch,&hostp) < 0)
  1067.             {
  1068.             fprintf(outfile,"\tpvm_config() : Failed with error %d\n",info);
  1069.             return -1;
  1070.             }
  1071.         sleep(1);
  1072.         count++;
  1073.         }
  1074. /*putc('\n',stderr);*/
  1075. if (actual_num != (number+1))
  1076.     {
  1077.     fprintf(outfile,"\tAdd/Del Timeout exceded.\n");
  1078.     return -2;
  1079.     }
  1080.  
  1081. /*printf("Finalement j'ai actual_number -1 =%d et je voulais %d\n",actual_num-1,number);*/
  1082.  
  1083. return 1;
  1084. }
  1085.  
  1086.  
  1087. /********************************/
  1088. /*      timeout_wait_message    */
  1089. /********************************/
  1090.  
  1091. int     timeout_wait_message(tid,tag,host_num)
  1092. int     tid;
  1093. int     tag;
  1094. int     host_num;
  1095. {
  1096. int info,count=0;
  1097.  
  1098. /*putc('.',stderr);*/
  1099. while (((info = pvm_probe(tid,tag)) == 0)&&(count <= TIMEOUT_MESSAGE))
  1100.     {
  1101.     if (info <0) break;
  1102.     sleep (1);
  1103. /*          putc('.',stderr);*/
  1104.     count ++;
  1105.     }
  1106. /*putc('\n',stderr);*/
  1107. if (info == 0)
  1108.     {
  1109.     if (host_num == -1)
  1110.         fprintf(outfile,"\tMessage Timeout expired\n");
  1111.     else
  1112.         fprintf(outfile,"\tMessage Timeout expired from host %s\n",hostpool[host_num]);
  1113.  
  1114.     return -2;
  1115.     }
  1116. if (info > 0 ) return 1;
  1117. fprintf(outfile,"\tpvm_probe() : Failed with error %d\n",info);
  1118. return -1;
  1119. }
  1120.  
  1121.  
  1122. /********************************/
  1123. /*      timeout_wait_kill        */
  1124. /********************************/
  1125.  
  1126. int     timeout_wait_kill(tid,host_num)
  1127. int     tid;
  1128. int     host_num;
  1129. {
  1130. int info,count=0;
  1131.  
  1132. /*printf("Waiting for kill ...\n");*/
  1133. /*putc('.',stderr);*/
  1134. while (1)
  1135.     {
  1136.     info = pvm_pstat(tid);
  1137.     if (info <0) break;
  1138.     if (count > TIMEOUT_KILL) break;
  1139.     sleep (1);
  1140.     count ++;
  1141.     }
  1142. /*putc('\n',stderr);*/
  1143. if ((info !=PvmNoTask)&&(count < TIMEOUT_KILL))
  1144.     {
  1145.     if (host_num == -1)
  1146.         fprintf(outfile,"\tpvm_pstat() : Failed with error %d\n",info);
  1147.     else
  1148.         fprintf(outfile,"\tpvm_pstat() : Failed with error %d for host %s\n",
  1149.             info,hostpool[host_num]);
  1150.     return -1;
  1151.     }
  1152.  
  1153. if (count >= TIMEOUT_KILL)
  1154.     {
  1155.     if (host_num == -1)
  1156.         fprintf(outfile,"\tKill Timeout expired\n");
  1157.     else
  1158.         fprintf(outfile,"\tKill Timeout expired for host %s\n",
  1159.             hostpool[host_num]);
  1160.     return -2;
  1161.     }
  1162. if (info == PvmNoTask ) return 1;
  1163. fprintf(outfile,"\tpvm_pstat() : Failed with error %d\n",info);
  1164. return -1;
  1165. }
  1166.  
  1167.  
  1168. /*--------------------------------------*/
  1169. /*--------- Internal Stuff -------------*/
  1170. /*--------------------------------------*/
  1171.  
  1172. /*      parse_flag      */
  1173. int parse_flag(line)
  1174. char     *line;
  1175. {
  1176. if (line[1] == ']') return 0;
  1177. else if (line[1] == 'x') return 1;
  1178. else return -1;
  1179. }
  1180.  
  1181. /*      parse_test_number       */
  1182. int parse_test_number(line,flag)
  1183. char     *line;
  1184. int     flag;
  1185. {
  1186. int     j,i=0;
  1187. char     result[NUMBER_TEST_DIGITS];
  1188. char      c;
  1189.  
  1190. for(j=0;j<=NUMBER_TEST_DIGITS-1;j++) result[j]=' ';
  1191. result[NUMBER_TEST_DIGITS]='\0';
  1192.  
  1193. if (    (line[1+flag] != ']')||
  1194.     (line[2+flag] != 't')||
  1195.     (line[3+flag] != 'e')||
  1196.     (line[4+flag] != 's')||
  1197.     (line[5+flag] != 't')   )       return -1;
  1198.  
  1199. while( (c = line[6+i+flag]) != '\n')
  1200.         {
  1201.         if ((c!=' ')&&((isdigit(c) == 0))||(i>NUMBER_TEST_DIGITS)) return -1;
  1202.         result[i]=c;
  1203.         i++;
  1204.         }
  1205. return atoi(result);
  1206. }
  1207.